<template>
  <section>
      <div style="display:flex;flex-direction: row">
        <draggable v-model="items1" @update="datagragEnd" :options="{animation:500,group:'item'}" style="margin-right:10px;width:48%;border:1px solid orange">
          <transition-group style="border:1px solid greenyellow">
            <div v-for="item in items1" :key="item.text" class="drag-item">{{item.text}}</div>
          </transition-group>
        </draggable>
        <draggable v-model="items2" @update="datagragEnd" @change="changeEvt" :options="{group:'item'}" style="width:48%;border:1px solid orange">
          <div v-for="item in items2" :key="item.text" class="drag-item">{{item.text}}</div>
        </draggable>
      </div>
  </section>
</template>

<script>
  import draggable from 'vuedraggable'

  export default {
    components: {
      draggable
    },
    name: 'draggable-test',
    data() {
      return {
        items1: [
          {
            text: "第一个"
          }, {
            text: "第二个"
          }, {
            text: "第三个"
          }, {
            text: "第四个"
          }, {
            text: "第五个"
          }, {
            text: "第六个"
          }
        ],
        items2:[
        ]
      }
    },
    methods: {
      datagragEnd(evt) {
        //console.log(evt)

      },
      changeEvt(evt){
        console.log(evt)
        console.log(this.items2)
      }
    }
  }
</script>

<style lang="scss">
  .drag-item {
    border: 1px solid #666;
    line-height: 50px;
    margin: 10px;
    width:50px;
    height:50px;
    text-align: center;
    float:left;
  }
</style>
